/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.pdx.cs.guavadata.domain;


import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.lang.String;
import java.sql.ResultSet;
import java.util.Date;
/**
 *
 * @author VuTran
 */
public class DateTime extends Domain {

    @Override
    public boolean validate(Object o) {
        if (!(o instanceof DateTime)) return false;
        return true;
    }

    @Override
    public Object convertString(String s) throws DomainConversionException {
        if ((s == null) || (s == "")) return null;
        
        return new Date(s);
    }

    @Override
    public Class getNaiveType() {
        return Date.class;
    }

    @Override
    public String getDBType() {
        return "datetime";
    }

    @Override
    public boolean equals(Object obj) {
        return (obj instanceof DateTime);
    }

    @Override
    public int hashCode() {
        return Date.class.hashCode();
    }

    @Override
    public String toString() {
        return "DateTime";
    }

    @Override
    public Domain upcast() {
        return null;
    }

    @Override
    public Object upcastValue(Object o) throws Exception {
        return null;
    }

    @Override
    public Domain merge(Domain d) {
        if (d instanceof DateTime) return this;
        return null;
    }

    @Override
    public boolean isOrdered() {
        return true;
    }

    @Override
    public boolean canContain() {
        return false;
    }

    @Override
    public Domain clone() {
        return new DateTime();
    }

    @Override
    public Element ToXml(Document xdoc) {
        Element xe = xdoc.createElement("Domain");
        xe.setAttribute("Type", "DateTime");
        return xe;
    }

    public static DateTime fromElement(Element e) {
        return new DateTime();
    }

    public static DateTime fromDBInfoRow(ResultSet dr) {
        return new DateTime();
    }
}
